//
//  SheetTransition.swift
//  YouZhiYuan
//
//  Created by youzy01 on 2019/4/17.
//  Copyright © 2019 泽i. All rights reserved.
//

import UIKit

public class SheetTransition: NSObject {
    private var canTapDismiss: Bool

    public init(canTapDismiss: Bool = true) {
        self.canTapDismiss = canTapDismiss
        super.init()
    }
}

extension SheetTransition: UIViewControllerTransitioningDelegate {
    public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        let controller = SheetPresentationController(presentedViewController: presented, presenting: presenting)
        controller.canTapDismiss = canTapDismiss
        return controller
    }

    public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return SheetPresentAnimator()
    }

    public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return SheetDismissAnimator()
    }

    public func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return nil
    }

    public func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return nil
    }
}
